
// import Nevow.Athena

Planets.Planet = Nevow.Athena.Widget.subclass('Planets');
Planets.Planet.methods(
    function start(self, node, event) {
        self.callRemote('start');
        return false;
    },

    function stop(self, node, event) {
        self.callRemote('stop');
        return false;
    },

    function set_multiplier(self, node, event) {
        var multiplier = Nevow.Athena.NodeByAttribute(self.node, "id", "tick_multiplier_text").value;
        Nevow.Athena.NodeByAttribute(self.node, "id", "tick_multiplier_value").innerHTML = multiplier;
        self.callRemote('set_tick_multiplier', multiplier);
        return false
    },

    function setGoals(self, node, event) {
        var temp = new Array()
        temp[0] = Nevow.Athena.NodeByAttribute(self.node, "id", "housing_goal").value;
        temp[1] = Nevow.Athena.NodeByAttribute(self.node, "id", "mining_goal").value;
        temp[2] = Nevow.Athena.NodeByAttribute(self.node, "id", "fooding_goal").value;
        temp[3] = Nevow.Athena.NodeByAttribute(self.node, "id", "ships_goal").value;
        temp[4] = Nevow.Athena.NodeByAttribute(self.node, "id", "troops_goal").value;
        temp[5] = Nevow.Athena.NodeByAttribute(self.node, "id", "researching_goal").value;
        temp[6] = Nevow.Athena.NodeByAttribute(self.node, "id", "health_goal").value;
        temp[7] = Nevow.Athena.NodeByAttribute(self.node, "id", "police_goal").value;
        temp[8] = Nevow.Athena.NodeByAttribute(self.node, "id", "military_goal").value;
        temp[9] = Nevow.Athena.NodeByAttribute(self.node, "id", "infrastructure_goal").value;
        temp[10] = Nevow.Athena.NodeByAttribute(self.node, "id", "entertainment_goal").value;
        temp[11] = Nevow.Athena.NodeByAttribute(self.node, "id", "unemployment_goal").value;
        self.callRemote('set_goals', temp);
        return false;
    },

    function setFields(self, toWhat) {
        Nevow.Athena.NodeByAttribute(self.node, "id", "tick").innerHTML = toWhat[0];
        Nevow.Athena.NodeByAttribute(self.node, "id", "population").innerHTML = toWhat[1];
        Nevow.Athena.NodeByAttribute(self.node, "id", "houses").innerHTML = toWhat[2];
        Nevow.Athena.NodeByAttribute(self.node, "id", "food").innerHTML = toWhat[3];
        Nevow.Athena.NodeByAttribute(self.node, "id", "metal").innerHTML = toWhat[4];
        Nevow.Athena.NodeByAttribute(self.node, "id", "research").innerHTML = toWhat[5];

        Nevow.Athena.NodeByAttribute(self.node, "id", "housing").innerHTML = toWhat[6];
        Nevow.Athena.NodeByAttribute(self.node, "id", "mining").innerHTML = toWhat[8];
        Nevow.Athena.NodeByAttribute(self.node, "id", "fooding").innerHTML = toWhat[10];
        Nevow.Athena.NodeByAttribute(self.node, "id", "ships").innerHTML = toWhat[12];
        Nevow.Athena.NodeByAttribute(self.node, "id", "troops").innerHTML = toWhat[14];
        Nevow.Athena.NodeByAttribute(self.node, "id", "researching").innerHTML = toWhat[16];
        Nevow.Athena.NodeByAttribute(self.node, "id", "health").innerHTML = toWhat[18];
        Nevow.Athena.NodeByAttribute(self.node, "id", "police").innerHTML = toWhat[20];
        Nevow.Athena.NodeByAttribute(self.node, "id", "military").innerHTML = toWhat[22];
        Nevow.Athena.NodeByAttribute(self.node, "id", "infrastructure").innerHTML = toWhat[24];
        Nevow.Athena.NodeByAttribute(self.node, "id", "entertainment").innerHTML = toWhat[26];
        Nevow.Athena.NodeByAttribute(self.node, "id", "unemployment").innerHTML = toWhat[28];

if (Nevow.Athena.NodeByAttribute(self.node, "id", "housing_goal").disabled) {
        Nevow.Athena.NodeByAttribute(self.node, "id", "housing_goal").value = toWhat[7];
        Nevow.Athena.NodeByAttribute(self.node, "id", "mining_goal").value = toWhat[9];
        Nevow.Athena.NodeByAttribute(self.node, "id", "fooding_goal").value = toWhat[11];
        Nevow.Athena.NodeByAttribute(self.node, "id", "ships_goal").value = toWhat[13];
        Nevow.Athena.NodeByAttribute(self.node, "id", "troops_goal").value = toWhat[15];
        Nevow.Athena.NodeByAttribute(self.node, "id", "researching_goal").value = toWhat[17];
        Nevow.Athena.NodeByAttribute(self.node, "id", "health_goal").value = toWhat[19];
        Nevow.Athena.NodeByAttribute(self.node, "id", "police_goal").value = toWhat[21];
        Nevow.Athena.NodeByAttribute(self.node, "id", "military_goal").value = toWhat[23];
        Nevow.Athena.NodeByAttribute(self.node, "id", "infrastructure_goal").value = toWhat[25];
        Nevow.Athena.NodeByAttribute(self.node, "id", "entertainment_goal").value = toWhat[27];
        Nevow.Athena.NodeByAttribute(self.node, "id", "unemployment_goal").value = toWhat[29];
}

    });
